Category Archives: How to Fix

The difference between “?” and “?:” introduced by php7

Real knowledge comes from practice
The test code
Input test:

<?php
    $array = [
        'a' => 1,
        'b' => 2,
        'c' => [],
    ];

    $a = $array['c'] ?? 0;
    $b = $array['c'] ?: 0;
    $c = $array['d'] ?? 0;
    $d = $array['d'] ?: 0;
    $e = $array['c'] ? 1 : 0;
    $f = isset($array['c']) ? 1 : 0;
    $g = $array['d'] ? 1 : 0;
    $h = isset($array['d']['e']) ? 1 : 0;
    $i = !empty($array['c']) ? 1 : 0;
    $j = !empty($array['d']) ? 1 : 0;

    var_dump($a);
    var_dump($b);
    var_dump($c);
    var_dump($d);
    var_dump($e);
    var_dump($f);
    var_dump($g);
    var_dump($h);
    var_dump($i);
    var_dump($j);
                      1234567891011121314151617181920212223242526272829

Output results:

PHP Notice:  Undefined index: d in /home/fanyu/abc.php on line 11PHP Notice:  Undefined index: d in /home/fanyu/abc.php on line 14array(0) {}int(0)int(0)int(0)int(0)int(1)int(0)int(0)int(0)int(0)1234567891011121314

conclusion

    $a ??0 equals isset($a)?$a: 0. $a ?: 0 equals $a?$a: 0. Empty: determines if a variable is empty (null, false, 00, 0, ‘0’, “, etc., all return true). Isset: determines if a variable isset (false, 00, 0, ‘0’, “etc., which also returns true).

plt.show () and plt.imshow The difference between ()

Problem: Plt.imShow () cannot display image
Solution: Add: plt.show(), i.e

Plt.imShow (image) #image represents the image to be processed
plt.show()

How It Works: The plt.imShow () function is responsible for processing the image and displaying its format, while plt.show() displays the function processed by plt.imShow ().

Python modifies word document content and inserts pictures

The following code

#!/usr/bin/python
# coding:utf-8
import docx
def main():
    filepath = 'test.docx'
    filepath1 = 'wtest.docx'
    newdocx = docx.Document(filepath)
    table = newdocx.tables
    for oTable in table:
        rows_num = len(oTable.rows)
        columns_num = len(oTable.columns)
        cell = oTable.cell(3, 0)
        # cell.add_paragraph("a")
        cell.text = ""
        cell.paragraphs[-1].runs[0].add_picture('t1.jpg')
        print(rows_num)
        print(columns_num)
        newdocx.save(filepath1)
if __name__ == '__main__':
    main()

No power supply specified for net vdda / vssa in power rail configuration

No Power Supply Specified for NET VDDA/VSSA in Power Rail Configuration

Problems encountered:



Solution:

Add VDDA, VSSA to VCC/VDD in power management Settings.

The menu bar – & gt; Design-> Powe Rail Configuration-> Uncheck the box “Use default power rail connections” ->; Name-> VCC/VDD-> Move VDDA and VSSA into it.



Conclusion:

hope to help you

Windows git review reported an error. UnicodeDecodeError

Traceback (most recent call last):
File “c:\gary\software\tool\python\python38-32\lib\runpy. py”, line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File “c:\gary\software\tool\python\python38-32\lib\runpy. py”, line 86, in _run_code
exec(code, run_globals)
File “C:\Gary\software\Tool\Python\Python38-32\Scripts\git-review.exe\__main__. py”, line 9, in <module>
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 1714, in main
_main()
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 1587, in _main
check_remote(branch, remote, config[‘scheme’],
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 781, in check_remote
has_color = check_color_support()
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 696, in check_color_support
(status, output) = run_command_status(test_command)
File “c:\gary\software\tool\python\python38-32\lib\site-packages\git_review\cmd. py”, line 140, in run_command_status
(out, nothing) = p.communicate(stdin)
File “c:\gary\software\tool\python\python38-32\lib\subprocess. py”, line 1011, in communicate
stdout = self.stdout.read()
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xa7 in position 21: illegal multibyte sequence

In the directory where python is installed, there is a file subprocess.py in Python38-32\Lib\ with encoding=NONE, change it to encoding=’utf-8′ and you can