您的位置:首页 > 编程语言 > Python开发

Python学习笔记(十一)

2017-10-20 18:50 337 查看
变量的输入输出

# coding:utf-8
str_1 = input("Enter a string:")
str_2 = input("Enter another string:")

print("str_1 is: " + str_1 + "str_2 is: " + str_2)
print("str_1 is {} + str_2 is {}".format(str_1, str_2))


文件的输入输出

#文件的输入输出
some_sentences = '''\
I love learning python
because python is fun
and also easy to use
'''
f = open('setences.txt','w')
f.write(some_sentences)
f.close

f = open('setences.txt')
while True:
line = f.readline()
if len(line) == 0:
break
print(line)
f.close
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python IO File-IO code-IO input