如何在Python中修复此TypeError?

时间:2019-05-06 16:46:47

标签: python python-3.x string ntp

我正在尝试创建一个NTP客户端,该客户端最终将以“ Mon May 10 07:29:23 EDT 2019”格式输出时间。

static class Program
{
    static void Main(string[] args)
    {
        // Write code here:
        var grid = new string[,] {
            {  "A", "B", "C", "D" },
            {  "P", "R", "A", "T" },
            {  "K", "I", "T", "A" },
            {  "A", "N", "D", "Y" }};

        Console.WriteLine(string.Join("|", grid.FindDiagonalWords(2, 1)));
        // (2,1) "I" => "PID|DAIA"
    }

    public static IEnumerable<string> FindDiagonalWords(this string[,] grid, int row, int column)
    {
        int numRows = grid.GetLength(0);
        int numCols = grid.GetLength(1);

        var sb = new StringBuilder();
        for (int i = 0; i < numRows; i++)
        {
            int j = (i-row)+column;
            if (j>=0 && j<numCols)
            {
                sb.Append(grid[i, j]);
            }
        }
        yield return sb.ToString();

        sb.Clear();
        for (int i = 0; i < numRows; i++)
        {
            int j = row+column-i;
            if (j>=0 && j<numCols)
            {
                sb.Append(grid[i, j]);
            }
        }
        yield return sb.ToString();
    }
}

我不断收到sendto行的以下错误:

host = "pool.ntp.org"; 
port = 123; 
address = ( host, port ); 
data = '\x1b' + 47 * '\0'; 

client = socket.socket( AF_INET, SOCK_DGRAM ); 

client.sendto( data, address );

我在理解此错误时遇到很多问题,所以我不知道如何解决。

0 个答案:

没有答案