小编Rae*_*ven的帖子

Python:strftime()UTC Offset在Windows中不能按预期工作

每次我使用:

time.strftime("%z")
Run Code Online (Sandbox Code Playgroud)

我明白了:

Eastern Daylight Time
Run Code Online (Sandbox Code Playgroud)

但是,我希望UTC偏移量为+ HHMM或-HHMM.我甚至尝试过:

time.strftime("%Z")
Run Code Online (Sandbox Code Playgroud)

仍然产生:

Eastern Daylight Time
Run Code Online (Sandbox Code Playgroud)

我已经阅读了几个与strftime()相关的其他帖子,%z似乎总是以正确的+ HHMM或-HHMM格式返回UTC偏移量.如何让strftime()以+ HHMM或-HHMM格式输出python 3.3?

编辑:我正在运行Windows 7

python windows utc strftime offset

14
推荐指数
2
解决办法
7255
查看次数

具有多个可执行文件的Makefile

我正在尝试编写一个makefile,它使用宏一次从多个文件创建多个可执行文件.我试着通过以前回答的问题进行搜索,但是因为我对C语言编程以及与gcc一起工作相当新,所以我无法找到问题的答案.

这是我到目前为止:

CC=gcc
CFLAGS=-I.
OBJ = ex1.c ex3.c
EXECUTABLE = ex1 ex3

$(EXECUTABLE): $(OBJ)
    gcc -o $@ $^ $(CFLAGS)

clean:
    rm -f $(EXECUTABLE)
Run Code Online (Sandbox Code Playgroud)

我想要这条线

$(EXECUTABLE): $(OBJ)
Run Code Online (Sandbox Code Playgroud)

分别从文件ex1.c ex3.c创建可执行文件ex1和ex3.

c makefile

8
推荐指数
1
解决办法
1万
查看次数

Theory Behind getchar() and putchar() Functions

I'm working through "The C Programming Language" by K&R and example 1.5 has stumped me:

#include <stdio.h>

/* copy input to output; 1st version */
int main(int argc, char *argv[])
{
    int c;

    while ((c = getchar()) != EOF)
        putchar(c);

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

I understand that 'getchar()' takes a character for 'putchar()' to display. However, when I run the program in terminal, why is it that I can pass an entire line of characters for 'putchar()' to display?

c putchar getchar

6
推荐指数
1
解决办法
4639
查看次数

重新连接 pySerial

我正在尝试编写一个连续读取串行输入的函数。该函数必须能够处理与串行端口的意外断开,并在可能的情况下重新连接。尽管阅读了 stackOverflow 上的几个问题帖子并浏览了 pySerial 文档,但我尚未找到解决方案。

这是我的代码:

def serialRead(serialPort, queue):
    """Adds serial port input to a queue."""

    ser = serial.Serial(serialPort - 1, timeout = 2)

    ser.parity = "O"
    ser.bytesize = 7

    while(True):
        try:
            if(ser == None):
                ser = serial.Serial(serialPort - 1, timeout = 2)

                ser.parity = "O"
                ser.bytesize = 7

                print("Reconnecting")

            queue.put(ser.read(27))
            ser.write(chr(6).encode())

            print("Writing Data...")

        except:
            if(not(ser == None)):
                ser.close()
                ser = None
                print("Disconnecting")

            print("No Connection")
            time.sleep(2)
Run Code Online (Sandbox Code Playgroud)

这是我的输出:

Enter a Serial Port: 7
Writing Data...
Writing Data...
Writing Data...
Writing Data... …
Run Code Online (Sandbox Code Playgroud)

python reconnect pyserial

5
推荐指数
1
解决办法
6459
查看次数

冲突类型

我正在通过 K&R C 工作,而 GCC 继续给我这个错误,例如 1.9:

arrays.c:4:5: error: conflicting types for ‘getline’
/usr/include/stdio.h:675:20: note: previous declaration of ‘getline’ was here
arrays.c:27:5: error: conflicting types for ‘getline’
/usr/include/stdio.h:675:20: note: previous declaration of ‘getline’ was here
make: *** [arrays] Error 1
Run Code Online (Sandbox Code Playgroud)

我的代码是:

#include <stdio.h>
#define MAXLINE 1000    /* maximum input line size */

int getline(char line[], int maxline);
void copy(char to[], char from[]);

/* print longest input line */
int main()
{
    int len;            /* current line length */
    int max; …
Run Code Online (Sandbox Code Playgroud)

c types conflict

4
推荐指数
1
解决办法
1636
查看次数

标签 统计

c ×3

python ×2

conflict ×1

getchar ×1

makefile ×1

offset ×1

putchar ×1

pyserial ×1

reconnect ×1

strftime ×1

types ×1

utc ×1

windows ×1