python - 如何将日期字符串添加到 URL?
问题描述
我有一些代码将今天的日期作为字符串使用
currnetdate = (pd.datetime.now().date())
然后在 URL 中,我有
main_api = 'https://www.sydneyairport.com.au/_a/flights/?query=&flightType=departure&terminalType=domestic&date=' + currnetdate + '&sortColumn=scheduled_time&ascending=true&showAll=true'
现在,当我运行代码时,我不断收到错误 TypeError: can only concatenate str (not "datetime.date") to str
解决方案
只需使用
str(currnetdate)
将日期时间对象转换为字符串。您也可以使用 f 字符串。
推荐阅读
- apache-kafka - kafka-reassign-partition.sh 不再接受 log_dirs 参数
- firebase - @ionic-native/firebase-dynamic-links 插件未公开 getDynamicLink 方法
- wordpress - 限制除特定域之外的所有人的文件下载访问权限
- javascript - 如何创建一个单独的具有公共 id 的 json 对象数组
- python - 如何将 python pandas 系列列附加到数据框?
- javascript - 如何在 Javascript 中查找儒略历上的当前日期
- c# - .NET VS win表单项目中的序列化顺序(设计器代码)问题
- delphi - Indy TIdSocksServer 不转发流量
- python - Keras 中的 DirectoryIterator
- swift - 使用 uibezierPath 以垂直方式画线