把美国州名String转换成2大写字母列表

# input
input_str = 'ak,ar,az,ca,ma'

# 可以先转换成大写字母,然后split by ','
output = input_str.upper().split(',')

# output
print(output)
['AK', 'AR', 'AZ', 'CA', 'MA']

Reference

Python String upper()

Leave a Comment

Your email address will not be published.