首页 \ 问答 \ 有了python,我怎么能在周三而不是周日或周一开始我的周开始?(With python how can I have the start of my weeks start on Wednesday instead of Sunday or Monday?)

有了python,我怎么能在周三而不是周日或周一开始我的周开始?(With python how can I have the start of my weeks start on Wednesday instead of Sunday or Monday?)

我正在使用gmtime, strftime and datetime.

为了给出上下文,我正在建立一个随叫随到的时间表,并且允许人们轻松切换人们的通话时间表我写了一个脚本来更改xml文件来完成它。 为了让每个随叫随到的人都更容易,我设置了脚本,以便您可以询问特定日期的周数。 大多数内置功能使用星期日或星期一作为开始日期,这不是我需要的。

有问题的功能:

我知道%U在星期天开始,我只需要一个解决方案,以便计算它在星期三开始。

`#option 2
def getWeek():
    print("\n\n")
    date = input("Enter the date you want the week number of (MM DD YYYY): ")
    if(len(date) != 10):
        print("You typed it in wrong. Try it again.")
        getWeek()
    else:
        d = time.strptime(date, "%m %d %Y")
        print(strftime("%U" + 2, d))`

I am using gmtime, strftime and datetime.

To give context I am setting up an on call schedule, and to allow people to easily switch people's on call schedules I wrote a script to change the xml file to accomplish that. To make it a bit easier on everyone on call I set the script up so that you can ask what the week number of a specific date is. Most of the built in functionality uses Sunday or Monday as the starting date, and that is not what I need.

The Function in question:

I know %U starts on Sunday, I just need a work around so that it will calculate for it to start on wednesday.

`#option 2
def getWeek():
    print("\n\n")
    date = input("Enter the date you want the week number of (MM DD YYYY): ")
    if(len(date) != 10):
        print("You typed it in wrong. Try it again.")
        getWeek()
    else:
        d = time.strptime(date, "%m %d %Y")
        print(strftime("%U" + 2, d))`

原文:https://stackoverflow.com/questions/39900627
更新时间:2023-11-02 15:11

最满意答案

它似乎是一个Windows问题。 替换:

this_application = WhoIsIAmApplication(this_device, args.ini.address)

有:

this_application = WhoIsIAmApplication(this_device, ('', 47808))

it seems to be a windows issue. Replaced :

this_application = WhoIsIAmApplication(this_device, args.ini.address)

with:

this_application = WhoIsIAmApplication(this_device, ('', 47808))

相关问答

更多
  • 确保服务器套接字(接收器)先运行,然后运行发送器套接字(发送器)意味着如果先发送发送器套接字,然后启动服务器套接字,则此连接失败时 ,发送器和接收器之间的起始差异为5到8秒错误可能会出现。 如果您正在使用从java.io发送大文件不是一个好的选择。请使用java.nio包处理大文件,请参阅http://www.coderpanda.com/java-socket-programming-transferring-large尺度的档案,通过插座/ Make sure that the server socke ...
  • 看起来这里有两个问题。 首先看起来设备根本没有响应。 这可能是由于配置问题test_bacnet1.config造成的。 你用来获取配置的命令行是什么? 其次,您在代理中使用的点名称与CSV文件中的点名称之间似乎不匹配。 请发布您的CSV文件的内容,以便我们可以看到可用的点名称。 编辑 (我们事先在电话中解决了这个问题,但我会在这里为后人添加它。) 问题是您没有提供设备ID和地址的正确组合。 地址始终是实际设备的地址,而不是可能恰好位于其前面的路由器。 设备ID始终是实际的设备ID。 从bacnet_sca ...
  • 您需要在虚拟设备命令行中包含子网掩码: python bacnet.py bacnet_registry.csv 10.0.2.5/24 您还应检查两个VM上的防火墙设置。 例如,CentOS默认阻止所有传入流量。 (您仍将在输出tcpdump中看到它。)对于BACnet,您需要为所有流量(广播和直接)打开udp端口47808。 You need to include the subnet mask in the virtual device command line: python bacnet.py ...
  • 服务器似乎错过了在侦听套接字上调用bind() 。 The server seems to miss calling bind() on the listening socket.
  • 这可能是一个错误的设备地址(如果设备存在于错误的地址,可能导致csv设备不匹配)或csv文件出现问题。 通常它会成为csv文件的问题。 This is either a bad device address (which could cause a csv to device mismatch if a device exists at the wrong address) or a problem with your csv file. Usually it's going to be a problem ...
  • 它似乎是一个Windows问题。 替换: this_application = WhoIsIAmApplication(this_device, args.ini.address) 有: this_application = WhoIsIAmApplication(this_device, ('', 47808)) it seems to be a windows issue. Replaced : this_application = WhoIsIAmApplication(this_device, ...
  • 通常套接字绑定在IPADDRESS和PORT编号上。 当您尝试使用相同的PORT编号再次绑定它时,它将通过错误。 您要么处置第一个连接(可能需要一段时间,在两次调用之间使用一些休眠),然后尝试再次绑定或使用不同的端口号。 Normally socket binds on IPADDRESS and PORT number. when you will try to bind it again using the same PORT number, it will through the error. Eit ...
  • 问题解决了 如果其他人有同样的问题,请检查您的UDP套接字。 在我的代码中,我创建了一个发送套接字和一个接收套接字,并将其中一个设置为非独占。 不幸的是,这样做时,发送套接字将阻止任何接收端口上的数据包进入 - 但是,它会让UDP广播通过,以便它看起来在部分时间内工作。 Problem Solved In case anyone else has the same problem, check your UDP sockets. In my code, I created a send socket and ...
  • 您可以使用1024以上的任何端口(操作系统保留Linux上的前1025个用于官方服务)。 你的问题是,如果你在蜂窝网络上,你将无法连接到手机,蜂窝网络不太可能让传入的连接通过。 如果你在无线网络上,你几乎肯定也有防火墙。 如果服务器和设备都在同一个wifi网络上,它只能工作。 You can use any port you want above 1024 (the OS reserves those top 1025 on Linux for official services). Your proble ...
  • 这是一个常见的错误。 实际上,当您设置bacnet代理时,您将创建一个新的BACnet设备并将其放置在网络上。 VOLTTRON平台BACnet驱动程序然后使用此设备与网络上的设备进行通信。 该设备与网络上的任何其他设备没有任何共同之处,除了它将与之通信的端口之外。 从BACnet代理文档: device_address - 绑定到运行VOLTTRON的计算机上通过其进行BACnet通信的网络端口的地址。 这不是任何目标设备的地址。 http://volttron.readthedocs.io/en/dev ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。