Board logo

标题: [文本处理] 批处理怎样将txt里面的文本内容全部转换成大写? [打印本页]

作者: luotexiaozh    时间: 2015-11-11 20:16     标题: 批处理怎样将txt里面的文本内容全部转换成大写?

有个文本文档 1.txt,里面的内容类似如下:
Alibaba Group saw its gross merchandize volume breaking last year's record within half a day after the 24-hour online shopping festival kicked off on Nov 11.

The e-commerce giant announced earlier Wednesday its unaudited figure, saying the gross merchandize volume on its Tmall platform reached 57.1 billion yuan ($8.98 billion) at 11:50 am and about 71.61 percent out of the volume generated from mobile channels, such as smartphones and tablets.

现在想把这个txt的内容全部转换成大写!!!
作者: 依山居    时间: 2015-11-11 20:24

本帖最后由 依山居 于 2015-11-11 20:29 编辑

http://batch-cn.qiniudn.com/tool/CCase.exe
  1. o( ̄▽ ̄)o 2015/11/11 周三20:28:50.40 <( ̄︶ ̄)>
  2. c:\>ccase /?
  3. CCase 2.7 - (C) 2004-2010 by Bill Stewart (bstewart@iname.com)
  4. Usage: ccase [-u | -l]
  5. -u  Converts to uppercase (default).
  6. -l  Converts to lowercase.
  7. Converts each line of standard input to upper or lowercase.
复制代码

作者: 依山居    时间: 2015-11-11 20:27

本帖最后由 依山居 于 2015-11-11 20:33 编辑
  1. with open("1.txt") as f:
  2. txt=f.read()
  3. upper=txt.upper()
  4. print(upper)
复制代码
大python
作者: 依山居    时间: 2015-11-11 20:34

  1. c:\>str /?
  2. Str 2.7 - (C) 2004-2010 by Bill Stewart (bstewart@iname.com)
  3. Usage: str [-c | -l | -u] string
  4.    or: str [-i] -p string1 string2
  5. -c  Echoes the number of character in string (count).
  6. -l  Echoes the specified string in lowercase.
  7. -u  Echoes the specified string in uppercase.
  8. -p  Echoes the starting position of string2 in string1 (-1 = not found).
  9. -i  Specifies a case-insensitive comparison (must appear before -p).
复制代码
http://batch-cn.qiniudn.com/tool/Str.exe
作者: DAIC    时间: 2015-11-11 22:59

  1. gawk "{print toupper($0)}" 1.txt > 2.txt
复制代码

作者: DAIC    时间: 2015-11-11 23:00

  1. sed "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/" 1.txt > 2.txt
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2