“Python 练习实例”的版本间的差异

来自linux中国网wiki
跳到导航 跳到搜索
 
第31行: 第31行:
 
</pre>
 
</pre>
  
 
+
=see also=
 +
https://www.runoob.com/python3/python3-upper-lower.html
 
[[category:python]]
 
[[category:python]]

2020年10月19日 (一) 09:56的最新版本

98


cat 98.py 
#!/usr/bin/python
# -*- coding: utf-8 -*-
#py2
if __name__ == '__main__':
    fp = open('test.txt','w')
    string = raw_input('please input a string:\n')
    string = string.upper()
    fp.write(string)
    fp = open('test.txt','r')
    print fp.read()
    fp.close()


#py3 
#在 Python3.x 中 raw_input( ) 和 input( ) 进行了整合,去除了 raw_input( ),仅保留了 input( ) 函数,其接收任意任性输入,将所有输入默认为字符串处理,并返回字符串类型






see also

https://www.runoob.com/python3/python3-upper-lower.html