wei/unit_5/cars.py

13 lines
332 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

cars = ['audi', 'bmw', 'subaru', 'toyota']
for car in cars:
#判断当car是bmw的时候全大写打印其他首字母大写打印
if car == 'bmw':
print(car.upper())
else:
print(car.title())
car = 'Audi'
#lower可将变量转换为小写再判断是否相等
print(car.lower() == 'audi')
print(car)