- 阅读权限
- 255
- 威望
- 0 级
- 论坛币
- 146 个
- 通用积分
- 5.3500
- 学术水平
- 0 点
- 热心指数
- 4 点
- 信用等级
- 0 点
- 经验
- 4690 点
- 帖子
- 187
- 精华
- 0
- 在线时间
- 357 小时
- 注册时间
- 2012-9-24
- 最后登录
- 2024-8-15
博士生
还不是VIP/贵宾
- 威望
- 0 级
- 论坛币
 - 146 个
- 通用积分
- 5.3500
- 学术水平
- 0 点
- 热心指数
- 4 点
- 信用等级
- 0 点
- 经验
- 4690 点
- 帖子
- 187
- 精华
- 0
- 在线时间
- 357 小时
- 注册时间
- 2012-9-24
- 最后登录
- 2024-8-15
 | 开心 2024-2-20 11:49:49 |
|---|
签到天数: 24 天 连续签到: 1 天 [LV.4]偶尔看看III
|
经管之家送您一份
应届毕业生专属福利!
求职就业群
感谢您参与论坛问题回答
经管之家送您两个论坛币!
+2 论坛币
- # -*- coding: utf-8 -*-
- states = [
- 'oregon': 'or', 运行时老是提示,冒号错误,是在英文半角下写的,但是还是出错,求解
- 'florida':'fl',
- 'california':'ca',
- 'new york':'ny'
-
- ]
- cities = [
- 'ca':'sanfrancisco'
- 'mi':'detroit'
- 'fl':'jackonvile'
- ]
- cities['ny'] = 'new york'
- cities['or'] = 'portland'
- print '-' * 10
- print 'ny state has:',cities['ny']
- print 'or state has:',cities['or']
- print '-'*10
- print 'michigan abbreviation is :',states['michigan']
- print 'florida abbreviation is :',states['florida']
- print '-'*10
- print "michigan has:",cities[states['michigan']]
- print "florida has ",cities[states['florida']]
- print '-' * 10
- for state,abbrev in states.item():
- print "%s is abbreviated %s" %(state,abbrev)
- print '-' * 10
- for state,abbrev in states.items():
- print "%s state is abbreviated %s and has city %s" %(state,abbrev,cities[abbrev])
- print '-' * 10
- state = states.get('texas',none)
- if not state:
- print "sorry ,no texas"
- city = cities.get('tx','does not exist')
- print "the city for the state 'tx' is :%s"%city
- 报错提示# -*- coding: utf-8 -*-
- states = [
- 'oregon': 'or',
- 'florida':'fl',
- 'california':'ca',
- 'new york':'ny'
-
- ]
- cities = [
- 'ca':'sanfrancisco'
- 'mi':'detroit'
- 'fl':'jackonvile'
- ]
- cities['ny'] = 'new york'
- cities['or'] = 'portland'
- print '-' * 10
- print 'ny state has:',cities['ny']
- print 'or state has:',cities['or']
- print '-'*10
- print 'michigan abbreviation is :',states['michigan']
- print 'florida abbreviation is :',states['florida']
- print '-'*10
- print "michigan has:",cities[states['michigan']]
- print "florida has ",cities[states['florida']]
- print '-' * 10
- for state,abbrev in states.item():
- print "%s is abbreviated %s" %(state,abbrev)
- print '-' * 10
- for state,abbrev in states.items():
- print "%s state is abbreviated %s and has city %s" %(state,abbrev,cities[abbrev])
- print '-' * 10
- state = states.get('texas',none)
- if not state:
- print "sorry ,no texas"
- city = cities.get('tx','does not exist')
- print "the city for the state 'tx' is :%s"%city
复制代码
扫码加我 拉你入群
请注明:姓名-公司-职位
以便审核进群资格,未注明则拒绝
|
|
|