python编程问题

yujianshanzhuang1 2017-09-05 10:58:35
# coding=utf-8
A = 2
print(A)

word = 'words' * 3
print(word)
word = 'a long word '
mun = 16
string = 'bang!'
total = string * (mun - len(word))
print(total)

a = 'friends'
find_the_evil_in_your_friends = a[0] + a[2:4] + a[-3:-1]
print(find_the_evil_in_your_friends)

b='18811406334'
b1=b.replace(b[:8],'*'*8)
print(b1)

search='16'
a='1386-168-0006'
b='1681-222-0006'
print(search + ' is at '+ str(a.find(search))+ ' to '+ str(a.find(search)+len(search))+' of a ' )
print(search + ' is at '+ str(b.find(search))+ ' to '+ str(b.find(search)+len(search))+' of b ' )

print('{} a is a {}'.format('With','word'))

city = input("yinchuan")
url = "The city is {}".format(city)

city = input("yinchua")
url = "The city is {}".format(city)

def f(c):
f-=c*9/5+32
return str(f)+'f'
c1=f(35)
print (c1)


运行这段Python代码时,只运行到第一个url = "The city is {}".format(city),之后的无法显示结果,请问是什么原因?请大神指教
...全文
133 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sanGuo_uu 2017-09-05
  • 打赏
  • 举报
回复
1,city = input("yinchuan")这2个input是你要输入,才会下一步(这就是它为什么停住的原因) 2,f-=c*9/5+32,这一句有问题,你f没有声明,它没法进行-=操作
sanGuo_uu 2017-09-05
  • 打赏
  • 举报
回复
把f-=那个改成f= 其它的,执行py文件,如下:(你自己对比下,它停住的时候有光标闪动,直接输入就可以)
C:\Users\zzzz>python3 D:/testP/tt.py
2
wordswordswords
bang!bang!bang!bang!
fiend
********334
16 is at 5 to 7 of a
16 is at 0 to 2 of b
With a is a word
yinchuanxxx
yinchuayyy
95.0f
yujianshanzhuang1 2017-09-05
  • 打赏
  • 举报
回复
这个在哪里输入啊?下面不是直接显示'Yinchuan'了吗?

37,721

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧