我正在尝试将字符串中的字符转换为Python中的ascii值
喜欢ord('a [i]')但ord只期待字符不是字符串!!
在python中有没有其他方法可以解决这个问题.
我正在尝试将两个字符串值转换为单个dict
string1='red blue white'
string2= 'first second third'
dict={'red':first,'blue':second.'white':third}
Run Code Online (Sandbox Code Playgroud)
但在这里我不能使用循环!! 没有循环还有其他方法吗?帮我!!谢谢
例如,input1、input2变量和key_loc是字典的键列表,
输入:
input1='sam,geti,1234'
input2='jhon,somwhre,676966'
key_loc =['name','addr','phone']
Run Code Online (Sandbox Code Playgroud)
我期待以下格式的输出。
输出:
output={'recod1:{'name':'sam','addr':'geti','phone':'12343'},
'record2':{'name':'jhon','addr':'somewhre','phone':'676966'}}
Run Code Online (Sandbox Code Playgroud)
我们如何在 python 中做到这一点?